package com.razorthink.shell.utils;

import java.util.Date;

import org.apache.log4j.Logger;

public class CommandLogger {
	static Logger logger = Logger.getLogger("["
			+ new Date(System.currentTimeMillis()) + "]");

	public static Logger getLogger() {
		if (logger == null) {
			logger = Logger.getLogger("logfile");
		}
		return logger;
	}

	public static void logError(Object obj) {
		if (obj instanceof Exception) {
			getLogger()
					.error(CommonUtils.getExceptionAsString((Exception) obj));
		} else
			getLogger().error(obj);
	}

	public static void logInfo(Object obj) {
		if (obj instanceof Exception) {
			getLogger().info(CommonUtils.getExceptionAsString((Exception) obj));
		} else {
			getLogger().info(obj);
		}
	}
}
